package cn.itcast.servlet;

import cn.itcast.service.CustomerService;
import cn.itcast.vo.Customer;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class InitUpdateServlet
  extends HttpServlet
{
  private static final long serialVersionUID = -4880159258734225637L;
  
  public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
  {
    String id = request.getParameter("id");
    
    CustomerService cs = new CustomerService();
    
    Customer c = cs.findById(id);
    
    request.setAttribute("c", c);
    request.getRequestDispatcher("/pages/update.jsp").forward(request, response);
  }
  
  public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
  {
    doGet(request, response);
  }
}
